<?php
  require_once('./db.php');

  $_POST = array_map('mysql_real_escape_string',$_POST);
  $_POST = array_map('strip_tags',$_POST);
  $_POST = array_map('trim',$_POST);

  pr($_POST);

  $_POST['added_date'] = date('Y-m-d H:i:s');
  $_POST['status'] = '1';
  $insertQuery  = "INSERT INTO `users` SET ";
  foreach($_POST as $colName=>$value) {
    $insertQuery .= "`$colName`='$value' ,";
  }
  $insertQuery = rtrim($insertQuery,' ,');
  mysql_query($insertQuery);
  $id = mysql_insert_id();
  echo "Record Inserted On ID :$id";
  pq($insertQuery);
?>

<form action="" method="post">
  <table  border="1" cellpadding="0" cellspacing="0" width="80%" align="center">
    <thead>
      <tr>
        <th colspan="2">-:Please fill the details below:-</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td align="right">Username :</td>
        <td ><input type="text" name="uname" placeholder="User Name" required /></td>
      </tr>
      <tr>
        <td align="right">Email :</td>
        <td ><input type="email" name="email" placeholder="Please add e-mail" required /></td>
      </tr>
      <tr>
        <td align="right">Password :</td>
        <td ><input type="password" name="password" placeholder="Please add password" required /></td>
      </tr>
      <tr>
        <td align="right">&nbsp;</td>
        <td ><input type="submit" value="Please add !!" /></td>
      </tr>
    </tbody>
  </table>

</form>
